From ef35522d9ad23002df77ef0531f462424168e2d9 Mon Sep 17 00:00:00 2001 From: parkrrrr Date: Wed, 19 Oct 2005 16:13:36 +0000 Subject: [PATCH] Added some more default options, renamed 'symbol' to 'deficon' for consistency. --- gpsbabel/README | 12 +++++- gpsbabel/an1.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 109 insertions(+), 4 deletions(-) diff --git a/gpsbabel/README b/gpsbabel/README index 33da38c85..b4994988b 100644 --- a/gpsbabel/README +++ b/gpsbabel/README @@ -949,12 +949,22 @@ THE FORMATS gpsbabel -i gpx -f 12345.gpx -o an1,nogc -F 12345.an1 - The "symbol" option allows you to specify which symbol to use for + The "deficon" option allows you to specify which symbol to use for points that don't have a symbol already. It defaults to "Red Flag" but it accepts any symbol name you can put in a DeLorme export file. To find the name of a specific symbol in Street Atlas, let the mouse pointer hover over it for a few seconds and the name will be displayed. + The "color" option allows you to specify the color for line data. + It accepts color names of the form "#FF0000" (red) or any of the 16 + common color names from the Cascading Style Sheets specification.i + + The "zoom" option specifies at what zoom level Street Atlas will begin + showing reduced versions of your symbols. The default is 10. Setting + zoom to 0 will disable this feature. Setting it to anything but the + default will override the zoom level specified on any waypoints that + were read from an existing an1 file; this is by design. + GPSBabel has limited experimental support for other types of layers besides the default "drawing" layer with the use of two options: diff --git a/gpsbabel/an1.c b/gpsbabel/an1.c index 9139ebf14..006c4f5f9 100644 --- a/gpsbabel/an1.c +++ b/gpsbabel/an1.c @@ -33,8 +33,11 @@ static char *output_type = NULL; static char *road_changes = NULL; static char *nogc = NULL; static char *opt_symbol = NULL; +static char *opt_color = NULL; +static char *opt_zoom = NULL; static short output_type_num = 0; - +static short opt_zoom_num = 0; +static long opt_color_num = 0; static short last_read_type = 0; static long serial=10000; @@ -55,8 +58,12 @@ arglist_t an1_args[] = { "", ARGTYPE_HIDDEN | ARGTYPE_STRING }, {"nogc", &nogc, "Do not add geocache data to description", NULL, ARGTYPE_BOOL }, - {"symbol", &opt_symbol, "Symbol to use for point data", + {"deficon", &opt_symbol, "Symbol to use for point data", "Red Flag", ARGTYPE_STRING }, + {"color", &opt_color, "Color to use for line data", + "red", ARGTYPE_STRING }, + {"zoom", &opt_zoom, "Zoom level to reduce points", + NULL, ARGTYPE_INT }, {0, 0, 0, 0 } }; @@ -615,6 +622,8 @@ Write_One_AN1_Waypoint( const waypoint *wpt ) rec = (an1_waypoint_record *)fs; xfree( rec->name ); local = 0; + if ( opt_zoom ) + rec->visible_zoom = opt_zoom_num; } else { rec = Alloc_AN1_Waypoint(); @@ -626,6 +635,7 @@ Write_One_AN1_Waypoint( const waypoint *wpt ) rec->fontname = xstrdup( "Arial" ); FindIconByName( opt_symbol, &rec->guid ); rec->fontsize = 10; + rec->visible_zoom = opt_zoom?opt_zoom_num:10; } rec->name = xstrdup( wpt->description ); @@ -803,7 +813,7 @@ Write_One_AN1_Line( const route_head *rte ) rec->type = 2; rec->unk4 = 2; rec->lineweight = 6; - rec->linecolor = 255; /* red */ + rec->linecolor = opt_color_num; /* red */ rec->unk5 = 3; rec->unk8 = 2; break; @@ -995,6 +1005,87 @@ Init_Road_Changes( void ) xfree( copy ); } +int HexDigit( char hex ) { + const char *Digits = "0123456789ABCDEF"; + const char *digits = "0123456789abcdef"; + char * ofs = strchr( digits, hex ); + if ( ofs ) { + return ofs-digits; + } + + ofs = strchr( Digits, hex ); + if ( ofs ) { + return ofs-Digits; + } + return 0; +} + +int HexByte( char* hex ) { + int b = (HexDigit(hex[0])<<4)+HexDigit(hex[1]); + return b; +} + +void Init_Color( void ) { + if ( opt_color[0] == '#' ) { + opt_color_num = (HexByte( opt_color+1 )) + // red + (HexByte( opt_color+3 )<<8) + // green + (HexByte( opt_color+5 )<<16); // blue + } + else if ( !case_ignore_strcmp( opt_color, "aqua" ) || + !case_ignore_strcmp( opt_color, "cyan" )) { + opt_color_num = 0xffff00; + } + else if ( !case_ignore_strcmp( opt_color, "black" )) { + opt_color_num = 0x000000; + } + else if ( !case_ignore_strcmp( opt_color, "blue" )) { + opt_color_num = 0xff0000; + } + else if ( !case_ignore_strcmp( opt_color, "fuchsia" ) || + !case_ignore_strcmp( opt_color, "magenta" )) { + opt_color_num = 0xff00ff; + } + else if ( !case_ignore_strcmp( opt_color, "gray" )) { + opt_color_num = 0x808080; + } + else if ( !case_ignore_strcmp( opt_color, "green" )) { + opt_color_num = 0x008000; + } + else if ( !case_ignore_strcmp( opt_color, "lime" )) { + opt_color_num = 0x00ff00; + } + else if ( !case_ignore_strcmp( opt_color, "maroon" )) { + opt_color_num = 0x000080; + } + else if ( !case_ignore_strcmp( opt_color, "navy" )) { + opt_color_num = 0x800000; + } + else if ( !case_ignore_strcmp( opt_color, "olive" )) { + opt_color_num = 0x008080; + } + else if ( !case_ignore_strcmp( opt_color, "purple" )) { + opt_color_num = 0x800080; + } + else if ( !case_ignore_strcmp( opt_color, "red" )) { + opt_color_num = 0x0000ff; + } + else if ( !case_ignore_strcmp( opt_color, "silver" )) { + opt_color_num = 0xc0c0c0; + } + else if ( !case_ignore_strcmp( opt_color, "teal" )) { + opt_color_num = 0x808000; + } + else if ( !case_ignore_strcmp( opt_color, "white" )) { + opt_color_num = 0xffffff; + } + else if ( !case_ignore_strcmp( opt_color, "yellow" )) { + opt_color_num = 0x00ffff; + } + else { + fatal( MYNAME ": unrecognized color name\n" ); + } +} + static void rd_init(const char *fname) { @@ -1022,6 +1113,10 @@ wr_init(const char *fname) outfile = xfopen( fname, "wb", MYNAME ); Init_Output_Type(); Init_Road_Changes(); + Init_Color(); + if ( opt_zoom ) { + opt_zoom_num = atoi(opt_zoom); + } } static void -- 2.30.2